package com.atguigu.daijia.driver.service.impl;

import com.atguigu.daijia.common.result.Result;
import com.atguigu.daijia.driver.client.CosFeignClient;
import com.atguigu.daijia.driver.service.CosService;
import com.atguigu.daijia.model.vo.driver.CosUploadVo;
import com.qcloud.cos.COSClient;
import com.qcloud.cos.http.HttpMethodName;
import com.qcloud.cos.model.GeneratePresignedUrlRequest;
import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;

import java.net.URL;
import java.util.Date;

@Slf4j
@Service
@SuppressWarnings({"unchecked", "rawtypes"})
public class CosServiceImpl implements CosService {

  @Autowired
  private CosFeignClient cosFeignClient;

  // 文件上传接口
  @Override
  public CosUploadVo uploadFile(MultipartFile file, String path) {
    // 远程调用文件存储服务，实现文件上传
    Result<CosUploadVo> cosUploadVoResult = cosFeignClient.upload(file, path);
    // 提取并返回上传结果数据
    return cosUploadVoResult.getData();
  }
}
